home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / Programming / gcc-2.95.3-3 / info / gcc.info-14 < prev    next >
Encoding:
GNU Info File  |  2001-07-15  |  47.6 KB  |  1,089 lines

  1. This is Info file gcc.info, produced by Makeinfo version 1.68 from the
  2. input file ./gcc.texi.
  3.  
  4. INFO-DIR-SECTION Programming
  5. START-INFO-DIR-ENTRY
  6. * gcc: (gcc).                  The GNU Compiler Collection.
  7. END-INFO-DIR-ENTRY
  8.    This file documents the use and the internals of the GNU compiler.
  9.  
  10.    Published by the Free Software Foundation 59 Temple Place - Suite 330
  11. Boston, MA 02111-1307 USA
  12.  
  13.    Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
  14. 1999, 2000 Free Software Foundation, Inc.
  15.  
  16.    Permission is granted to make and distribute verbatim copies of this
  17. manual provided the copyright notice and this permission notice are
  18. preserved on all copies.
  19.  
  20.    Permission is granted to copy and distribute modified versions of
  21. this manual under the conditions for verbatim copying, provided also
  22. that the sections entitled "GNU General Public License" and "Funding
  23. for Free Software" are included exactly as in the original, and
  24. provided that the entire resulting derived work is distributed under
  25. the terms of a permission notice identical to this one.
  26.  
  27.    Permission is granted to copy and distribute translations of this
  28. manual into another language, under the above conditions for modified
  29. versions, except that the sections entitled "GNU General Public
  30. License" and "Funding for Free Software", and this permission notice,
  31. may be included in translations approved by the Free Software Foundation
  32. instead of in the original English.
  33.  
  34. 
  35. File: gcc.info,  Node: Temporaries,  Next: Copy Assignment,  Prev: Static Definitions,  Up: C++ Misunderstandings
  36.  
  37. Temporaries May Vanish Before You Expect
  38. ----------------------------------------
  39.  
  40.    It is dangerous to use pointers or references to *portions* of a
  41. temporary object.  The compiler may very well delete the object before
  42. you expect it to, leaving a pointer to garbage.  The most common place
  43. where this problem crops up is in classes like string classes,
  44. especially ones that define a conversion function to type `char *' or
  45. `const char *' - which is one reason why the standard `string' class
  46. requires you to call the `c_str' member function.  However, any class
  47. that returns a pointer to some internal structure is potentially
  48. subject to this problem.
  49.  
  50.    For example, a program may use a function `strfunc' that returns
  51. `string' objects, and another function `charfunc' that operates on
  52. pointers to `char':
  53.  
  54.      string strfunc ();
  55.      void charfunc (const char *);
  56.      
  57.      void
  58.      f ()
  59.      {
  60.        const char *p = strfunc().c_str();
  61.        ...
  62.        charfunc (p);
  63.        ...
  64.        charfunc (p);
  65.      }
  66.  
  67. In this situation, it may seem reasonable to save a pointer to the C
  68. string returned by the `c_str' member function and use that rather than
  69. call `c_str' repeatedly.  However, the temporary string created by the
  70. call to `strfunc' is destroyed after `p' is initialized, at which point
  71. `p' is left pointing to freed memory.
  72.  
  73.    Code like this may run successfully under some other compilers,
  74. particularly obsolete cfront-based compilers that delete temporaries
  75. along with normal local variables.  However, the GNU C++ behavior is
  76. standard-conforming, so if your program depends on late destruction of
  77. temporaries it is not portable.
  78.  
  79.    The safe way to write such code is to give the temporary a name,
  80. which forces it to remain until the end of the scope of the name.  For
  81. example:
  82.  
  83.      string& tmp = strfunc ();
  84.      charfunc (tmp.c_str ());
  85.  
  86. 
  87. File: gcc.info,  Node: Copy Assignment,  Prev: Temporaries,  Up: C++ Misunderstandings
  88.  
  89. Implicit Copy-Assignment for Virtual Bases
  90. ------------------------------------------
  91.  
  92.    When a base class is virtual, only one subobject of the base class
  93. belongs to each full object. Also, the constructors and destructors are
  94. invoked only once, and called from the most-derived class. However, such
  95. objects behave unspecified when being assigned. For example:
  96.  
  97.      struct Base{
  98.        char *name;
  99.        Base(char *n) : name(strdup(n)){}
  100.        Base& operator= (const Base& other){
  101.         free (name);
  102.         name = strdup (other.name);
  103.        }
  104.      };
  105.      
  106.      struct A:virtual Base{
  107.        int val;
  108.        A():Base("A"){}
  109.      };
  110.      
  111.      struct B:virtual Base{
  112.        int bval;
  113.        B():Base("B"){}
  114.      };
  115.      
  116.      struct Derived:public A, public B{
  117.        Derived():Base("Derived"){}
  118.      };
  119.      
  120.      void func(Derived &d1, Derived &d2)
  121.      {
  122.        d1 = d2;
  123.      }
  124.  
  125.    The C++ standard specifies that `Base::Base' is only called once
  126. when constructing or copy-constructing a Derived object. It is
  127. unspecified whether `Base::operator=' is called more than once when the
  128. implicit copy-assignment for Derived objects is invoked (as it is
  129. inside `func' in the example).
  130.  
  131.    g++ implements the "intuitive" algorithm for copy-assignment: assign
  132. all direct bases, then assign all members. In that algorithm, the
  133. virtual base subobject can be encountered many times. In the example,
  134. copying proceeds in the following order: `val', `name' (via `strdup'),
  135. `bval', and `name' again.
  136.  
  137.    If application code relies on copy-assignment, a user-defined
  138. copy-assignment operator removes any uncertainties. With such an
  139. operator, the application can define whether and how the virtual base
  140. subobject is assigned.
  141.  
  142. 
  143. File: gcc.info,  Node: Protoize Caveats,  Next: Non-bugs,  Prev: C++ Misunderstandings,  Up: Trouble
  144.  
  145. Caveats of using `protoize'
  146. ===========================
  147.  
  148.    The conversion programs `protoize' and `unprotoize' can sometimes
  149. change a source file in a way that won't work unless you rearrange it.
  150.  
  151.    * `protoize' can insert references to a type name or type tag before
  152.      the definition, or in a file where they are not defined.
  153.  
  154.      If this happens, compiler error messages should show you where the
  155.      new references are, so fixing the file by hand is straightforward.
  156.  
  157.    * There are some C constructs which `protoize' cannot figure out.
  158.      For example, it can't determine argument types for declaring a
  159.      pointer-to-function variable; this you must do by hand.  `protoize'
  160.      inserts a comment containing `???' each time it finds such a
  161.      variable; so you can find all such variables by searching for this
  162.      string.  ANSI C does not require declaring the argument types of
  163.      pointer-to-function types.
  164.  
  165.    * Using `unprotoize' can easily introduce bugs.  If the program
  166.      relied on prototypes to bring about conversion of arguments, these
  167.      conversions will not take place in the program without prototypes.
  168.      One case in which you can be sure `unprotoize' is safe is when you
  169.      are removing prototypes that were made with `protoize'; if the
  170.      program worked before without any prototypes, it will work again
  171.      without them.
  172.  
  173.      You can find all the places where this problem might occur by
  174.      compiling the program with the `-Wconversion' option.  It prints a
  175.      warning whenever an argument is converted.
  176.  
  177.    * Both conversion programs can be confused if there are macro calls
  178.      in and around the text to be converted.  In other words, the
  179.      standard syntax for a declaration or definition must not result
  180.      from expanding a macro.  This problem is inherent in the design of
  181.      C and cannot be fixed.  If only a few functions have confusing
  182.      macro calls, you can easily convert them manually.
  183.  
  184.    * `protoize' cannot get the argument types for a function whose
  185.      definition was not actually compiled due to preprocessing
  186.      conditionals.  When this happens, `protoize' changes nothing in
  187.      regard to such a function.  `protoize' tries to detect such
  188.      instances and warn about them.
  189.  
  190.      You can generally work around this problem by using `protoize' step
  191.      by step, each time specifying a different set of `-D' options for
  192.      compilation, until all of the functions have been converted.
  193.      There is no automatic way to verify that you have got them all,
  194.      however.
  195.  
  196.    * Confusion may result if there is an occasion to convert a function
  197.      declaration or definition in a region of source code where there
  198.      is more than one formal parameter list present.  Thus, attempts to
  199.      convert code containing multiple (conditionally compiled) versions
  200.      of a single function header (in the same vicinity) may not produce
  201.      the desired (or expected) results.
  202.  
  203.      If you plan on converting source files which contain such code, it
  204.      is recommended that you first make sure that each conditionally
  205.      compiled region of source code which contains an alternative
  206.      function header also contains at least one additional follower
  207.      token (past the final right parenthesis of the function header).
  208.      This should circumvent the problem.
  209.  
  210.    * `unprotoize' can become confused when trying to convert a function
  211.      definition or declaration which contains a declaration for a
  212.      pointer-to-function formal argument which has the same name as the
  213.      function being defined or declared.  We recommand you avoid such
  214.      choices of formal parameter names.
  215.  
  216.    * You might also want to correct some of the indentation by hand and
  217.      break long lines.  (The conversion programs don't write lines
  218.      longer than eighty characters in any case.)
  219.  
  220. 
  221. File: gcc.info,  Node: Non-bugs,  Next: Warnings and Errors,  Prev: Protoize Caveats,  Up: Trouble
  222.  
  223. Certain Changes We Don't Want to Make
  224. =====================================
  225.  
  226.    This section lists changes that people frequently request, but which
  227. we do not make because we think GCC is better without them.
  228.  
  229.    * Checking the number and type of arguments to a function which has
  230.      an old-fashioned definition and no prototype.
  231.  
  232.      Such a feature would work only occasionally--only for calls that
  233.      appear in the same file as the called function, following the
  234.      definition.  The only way to check all calls reliably is to add a
  235.      prototype for the function.  But adding a prototype eliminates the
  236.      motivation for this feature.  So the feature is not worthwhile.
  237.  
  238.    * Warning about using an expression whose type is signed as a shift
  239.      count.
  240.  
  241.      Shift count operands are probably signed more often than unsigned.
  242.      Warning about this would cause far more annoyance than good.
  243.  
  244.    * Warning about assigning a signed value to an unsigned variable.
  245.  
  246.      Such assignments must be very common; warning about them would
  247.      cause more annoyance than good.
  248.  
  249.    * Warning about unreachable code.
  250.  
  251.      It's very common to have unreachable code in machine-generated
  252.      programs.  For example, this happens normally in some files of GNU
  253.      C itself.
  254.  
  255.    * Warning when a non-void function value is ignored.
  256.  
  257.      Coming as I do from a Lisp background, I balk at the idea that
  258.      there is something dangerous about discarding a value.  There are
  259.      functions that return values which some callers may find useful;
  260.      it makes no sense to clutter the program with a cast to `void'
  261.      whenever the value isn't useful.
  262.  
  263.    * Assuming (for optimization) that the address of an external symbol
  264.      is never zero.
  265.  
  266.      This assumption is false on certain systems when `#pragma weak' is
  267.      used.
  268.  
  269.    * Making `-fshort-enums' the default.
  270.  
  271.      This would cause storage layout to be incompatible with most other
  272.      C compilers.  And it doesn't seem very important, given that you
  273.      can get the same result in other ways.  The case where it matters
  274.      most is when the enumeration-valued object is inside a structure,
  275.      and in that case you can specify a field width explicitly.
  276.  
  277.    * Making bitfields unsigned by default on particular machines where
  278.      "the ABI standard" says to do so.
  279.  
  280.      The ANSI C standard leaves it up to the implementation whether a
  281.      bitfield declared plain `int' is signed or not.  This in effect
  282.      creates two alternative dialects of C.
  283.  
  284.      The GNU C compiler supports both dialects; you can specify the
  285.      signed dialect with `-fsigned-bitfields' and the unsigned dialect
  286.      with `-funsigned-bitfields'.  However, this leaves open the
  287.      question of which dialect to use by default.
  288.  
  289.      Currently, the preferred dialect makes plain bitfields signed,
  290.      because this is simplest.  Since `int' is the same as `signed int'
  291.      in every other context, it is cleanest for them to be the same in
  292.      bitfields as well.
  293.  
  294.      Some computer manufacturers have published Application Binary
  295.      Interface standards which specify that plain bitfields should be
  296.      unsigned.  It is a mistake, however, to say anything about this
  297.      issue in an ABI.  This is because the handling of plain bitfields
  298.      distinguishes two dialects of C.  Both dialects are meaningful on
  299.      every type of machine.  Whether a particular object file was
  300.      compiled using signed bitfields or unsigned is of no concern to
  301.      other object files, even if they access the same bitfields in the
  302.      same data structures.
  303.  
  304.      A given program is written in one or the other of these two
  305.      dialects.  The program stands a chance to work on most any machine
  306.      if it is compiled with the proper dialect.  It is unlikely to work
  307.      at all if compiled with the wrong dialect.
  308.  
  309.      Many users appreciate the GNU C compiler because it provides an
  310.      environment that is uniform across machines.  These users would be
  311.      inconvenienced if the compiler treated plain bitfields differently
  312.      on certain machines.
  313.  
  314.      Occasionally users write programs intended only for a particular
  315.      machine type.  On these occasions, the users would benefit if the
  316.      GNU C compiler were to support by default the same dialect as the
  317.      other compilers on that machine.  But such applications are rare.
  318.      And users writing a program to run on more than one type of
  319.      machine cannot possibly benefit from this kind of compatibility.
  320.  
  321.      This is why GCC does and will treat plain bitfields in the same
  322.      fashion on all types of machines (by default).
  323.  
  324.      There are some arguments for making bitfields unsigned by default
  325.      on all machines.  If, for example, this becomes a universal de
  326.      facto standard, it would make sense for GCC to go along with it.
  327.      This is something to be considered in the future.
  328.  
  329.      (Of course, users strongly concerned about portability should
  330.      indicate explicitly in each bitfield whether it is signed or not.
  331.      In this way, they write programs which have the same meaning in
  332.      both C dialects.)
  333.  
  334.    * Undefining `__STDC__' when `-ansi' is not used.
  335.  
  336.      Currently, GCC defines `__STDC__' as long as you don't use
  337.      `-traditional'.  This provides good results in practice.
  338.  
  339.      Programmers normally use conditionals on `__STDC__' to ask whether
  340.      it is safe to use certain features of ANSI C, such as function
  341.      prototypes or ANSI token concatenation.  Since plain `gcc' supports
  342.      all the features of ANSI C, the correct answer to these questions
  343.      is "yes".
  344.  
  345.      Some users try to use `__STDC__' to check for the availability of
  346.      certain library facilities.  This is actually incorrect usage in
  347.      an ANSI C program, because the ANSI C standard says that a
  348.      conforming freestanding implementation should define `__STDC__'
  349.      even though it does not have the library facilities.  `gcc -ansi
  350.      -pedantic' is a conforming freestanding implementation, and it is
  351.      therefore required to define `__STDC__', even though it does not
  352.      come with an ANSI C library.
  353.  
  354.      Sometimes people say that defining `__STDC__' in a compiler that
  355.      does not completely conform to the ANSI C standard somehow
  356.      violates the standard.  This is illogical.  The standard is a
  357.      standard for compilers that claim to support ANSI C, such as `gcc
  358.      -ansi'--not for other compilers such as plain `gcc'.  Whatever the
  359.      ANSI C standard says is relevant to the design of plain `gcc'
  360.      without `-ansi' only for pragmatic reasons, not as a requirement.
  361.  
  362.      GCC normally defines `__STDC__' to be 1, and in addition defines
  363.      `__STRICT_ANSI__' if you specify the `-ansi' option.  On some
  364.      hosts, system include files use a different convention, where
  365.      `__STDC__' is normally 0, but is 1 if the user specifies strict
  366.      conformance to the C Standard.  GCC follows the host convention
  367.      when processing system include files, but when processing user
  368.      files it follows the usual GNU C convention.
  369.  
  370.    * Undefining `__STDC__' in C++.
  371.  
  372.      Programs written to compile with C++-to-C translators get the
  373.      value of `__STDC__' that goes with the C compiler that is
  374.      subsequently used.  These programs must test `__STDC__' to
  375.      determine what kind of C preprocessor that compiler uses: whether
  376.      they should concatenate tokens in the ANSI C fashion or in the
  377.      traditional fashion.
  378.  
  379.      These programs work properly with GNU C++ if `__STDC__' is defined.
  380.      They would not work otherwise.
  381.  
  382.      In addition, many header files are written to provide prototypes
  383.      in ANSI C but not in traditional C.  Many of these header files
  384.      can work without change in C++ provided `__STDC__' is defined.  If
  385.      `__STDC__' is not defined, they will all fail, and will all need
  386.      to be changed to test explicitly for C++ as well.
  387.  
  388.    * Deleting "empty" loops.
  389.  
  390.      Historically, GCC has not deleted "empty" loops under the
  391.      assumption that the most likely reason you would put one in a
  392.      program is to have a delay, so deleting them will not make real
  393.      programs run any faster.
  394.  
  395.      However, the rationale here is that optimization of a nonempty loop
  396.      cannot produce an empty one, which holds for C but is not always
  397.      the case for C++.
  398.  
  399.      Moreover, with `-funroll-loops' small "empty" loops are already
  400.      removed, so the current behavior is both sub-optimal and
  401.      inconsistent and will change in the future.
  402.  
  403.    * Making side effects happen in the same order as in some other
  404.      compiler.
  405.  
  406.      It is never safe to depend on the order of evaluation of side
  407.      effects.  For example, a function call like this may very well
  408.      behave differently from one compiler to another:
  409.  
  410.           void func (int, int);
  411.           
  412.           int i = 2;
  413.           func (i++, i++);
  414.  
  415.      There is no guarantee (in either the C or the C++ standard language
  416.      definitions) that the increments will be evaluated in any
  417.      particular order.  Either increment might happen first.  `func'
  418.      might get the arguments `2, 3', or it might get `3, 2', or even
  419.      `2, 2'.
  420.  
  421.    * Not allowing structures with volatile fields in registers.
  422.  
  423.      Strictly speaking, there is no prohibition in the ANSI C standard
  424.      against allowing structures with volatile fields in registers, but
  425.      it does not seem to make any sense and is probably not what you
  426.      wanted to do.  So the compiler will give an error message in this
  427.      case.
  428.  
  429. 
  430. File: gcc.info,  Node: Warnings and Errors,  Prev: Non-bugs,  Up: Trouble
  431.  
  432. Warning Messages and Error Messages
  433. ===================================
  434.  
  435.    The GNU compiler can produce two kinds of diagnostics: errors and
  436. warnings.  Each kind has a different purpose:
  437.  
  438.      *Errors* report problems that make it impossible to compile your
  439.      program.  GCC reports errors with the source file name and line
  440.      number where the problem is apparent.
  441.  
  442.      *Warnings* report other unusual conditions in your code that *may*
  443.      indicate a problem, although compilation can (and does) proceed.
  444.      Warning messages also report the source file name and line number,
  445.      but include the text `warning:' to distinguish them from error
  446.      messages.
  447.  
  448.    Warnings may indicate danger points where you should check to make
  449. sure that your program really does what you intend; or the use of
  450. obsolete features; or the use of nonstandard features of GNU C or C++.
  451. Many warnings are issued only if you ask for them, with one of the `-W'
  452. options (for instance, `-Wall' requests a variety of useful warnings).
  453.  
  454.    GCC always tries to compile your program if possible; it never
  455. gratuitously rejects a program whose meaning is clear merely because
  456. (for instance) it fails to conform to a standard.  In some cases,
  457. however, the C and C++ standards specify that certain extensions are
  458. forbidden, and a diagnostic *must* be issued by a conforming compiler.
  459. The `-pedantic' option tells GCC to issue warnings in such cases;
  460. `-pedantic-errors' says to make them errors instead.  This does not
  461. mean that *all* non-ANSI constructs get warnings or errors.
  462.  
  463.    *Note Options to Request or Suppress Warnings: Warning Options, for
  464. more detail on these and related command-line options.
  465.  
  466. 
  467. File: gcc.info,  Node: Bugs,  Next: Service,  Prev: Trouble,  Up: Top
  468.  
  469. Reporting Bugs
  470. **************
  471.  
  472.    Your bug reports play an essential role in making GCC reliable.
  473.  
  474.    When you encounter a problem, the first thing to do is to see if it
  475. is already known.  *Note Trouble::.  If it isn't known, then you should
  476. report the problem.
  477.  
  478.    Reporting a bug may help you by bringing a solution to your problem,
  479. or it may not.  (If it does not, look in the service directory; see
  480. *Note Service::..)  In any case, the principal function of a bug report
  481. is to help the entire community by making the next version of GCC work
  482. better.  Bug reports are your contribution to the maintenance of GCC.
  483.  
  484.    Since the maintainers are very overloaded, we cannot respond to every
  485. bug report.  However, if the bug has not been fixed, we are likely to
  486. send you a patch and ask you to tell us whether it works.
  487.  
  488.    In order for a bug report to serve its purpose, you must include the
  489. information that makes for fixing the bug.
  490.  
  491. * Menu:
  492.  
  493. * Criteria:  Bug Criteria.   Have you really found a bug?
  494. * Where: Bug Lists.         Where to send your bug report.
  495. * Reporting: Bug Reporting.  How to report a bug effectively.
  496. * Patches: Sending Patches.  How to send a patch for GCC.
  497. * Known: Trouble.            Known problems.
  498. * Help: Service.             Where to ask for help.
  499.  
  500. 
  501. File: gcc.info,  Node: Bug Criteria,  Next: Bug Lists,  Up: Bugs
  502.  
  503. Have You Found a Bug?
  504. =====================
  505.  
  506.    If you are not sure whether you have found a bug, here are some
  507. guidelines:
  508.  
  509.    * If the compiler gets a fatal signal, for any input whatever, that
  510.      is a compiler bug.  Reliable compilers never crash.
  511.  
  512.    * If the compiler produces invalid assembly code, for any input
  513.      whatever (except an `asm' statement), that is a compiler bug,
  514.      unless the compiler reports errors (not just warnings) which would
  515.      ordinarily prevent the assembler from being run.
  516.  
  517.    * If the compiler produces valid assembly code that does not
  518.      correctly execute the input source code, that is a compiler bug.
  519.  
  520.      However, you must double-check to make sure, because you may have
  521.      run into an incompatibility between GNU C and traditional C (*note
  522.      Incompatibilities::.).  These incompatibilities might be considered
  523.      bugs, but they are inescapable consequences of valuable features.
  524.  
  525.      Or you may have a program whose behavior is undefined, which
  526.      happened by chance to give the desired results with another C or
  527.      C++ compiler.
  528.  
  529.      For example, in many nonoptimizing compilers, you can write `x;'
  530.      at the end of a function instead of `return x;', with the same
  531.      results.  But the value of the function is undefined if `return'
  532.      is omitted; it is not a bug when GCC produces different results.
  533.  
  534.      Problems often result from expressions with two increment
  535.      operators, as in `f (*p++, *p++)'.  Your previous compiler might
  536.      have interpreted that expression the way you intended; GCC might
  537.      interpret it another way.  Neither compiler is wrong.  The bug is
  538.      in your code.
  539.  
  540.      After you have localized the error to a single source line, it
  541.      should be easy to check for these things.  If your program is
  542.      correct and well defined, you have found a compiler bug.
  543.  
  544.    * If the compiler produces an error message for valid input, that is
  545.      a compiler bug.
  546.  
  547.    * If the compiler does not produce an error message for invalid
  548.      input, that is a compiler bug.  However, you should note that your
  549.      idea of "invalid input" might be my idea of "an extension" or
  550.      "support for traditional practice".
  551.  
  552.    * If you are an experienced user of C or C++ (or Fortran or
  553.      Objective-C) compilers, your suggestions for improvement of GCC
  554.      are welcome in any case.
  555.  
  556. 
  557. File: gcc.info,  Node: Bug Lists,  Next: Bug Reporting,  Prev: Bug Criteria,  Up: Bugs
  558.  
  559. Where to Report Bugs
  560. ====================
  561.  
  562.    Send bug reports for the GNU Compiler Collection to
  563. `gcc-bugs@gcc.gnu.org'.  In accordance with the GNU-wide convention, in
  564. which bug reports for tool "foo" are sent to `bug-foo@gnu.org', the
  565. address `bug-gcc@gnu.org' may also be used; it will forward to the
  566. address given above.
  567.  
  568.    Please read `<URL:http://www.gnu.org/software/gcc/bugs.html>' for
  569. bug reporting instructions before you post a bug report.
  570.  
  571.    Often people think of posting bug reports to the newsgroup instead of
  572. mailing them.  This appears to work, but it has one problem which can be
  573. crucial: a newsgroup posting does not contain a mail path back to the
  574. sender.  Thus, if maintainers need more information, they may be unable
  575. to reach you.  For this reason, you should always send bug reports by
  576. mail to the proper mailing list.
  577.  
  578.    As a last resort, send bug reports on paper to:
  579.  
  580.      GNU Compiler Bugs
  581.      Free Software Foundation
  582.      59 Temple Place - Suite 330
  583.      Boston, MA 02111-1307, USA
  584.  
  585. 
  586. File: gcc.info,  Node: Bug Reporting,  Next: Sending Patches,  Prev: Bug Lists,  Up: Bugs
  587.  
  588. How to Report Bugs
  589. ==================
  590.  
  591.    You may find additional and/or more up-to-date instructions at
  592. `<URL:http://www.gnu.org/software/gcc/bugs.html>'.
  593.  
  594.    The fundamental principle of reporting bugs usefully is this:
  595. *report all the facts*.  If you are not sure whether to state a fact or
  596. leave it out, state it!
  597.  
  598.    Often people omit facts because they think they know what causes the
  599. problem and they conclude that some details don't matter.  Thus, you
  600. might assume that the name of the variable you use in an example does
  601. not matter.  Well, probably it doesn't, but one cannot be sure.
  602. Perhaps the bug is a stray memory reference which happens to fetch from
  603. the location where that name is stored in memory; perhaps, if the name
  604. were different, the contents of that location would fool the compiler
  605. into doing the right thing despite the bug.  Play it safe and give a
  606. specific, complete example.  That is the easiest thing for you to do,
  607. and the most helpful.
  608.  
  609.    Keep in mind that the purpose of a bug report is to enable someone to
  610. fix the bug if it is not known.  It isn't very important what happens if
  611. the bug is already known.  Therefore, always write your bug reports on
  612. the assumption that the bug is not known.
  613.  
  614.    Sometimes people give a few sketchy facts and ask, "Does this ring a
  615. bell?"  This cannot help us fix a bug, so it is basically useless.  We
  616. respond by asking for enough details to enable us to investigate.  You
  617. might as well expedite matters by sending them to begin with.
  618.  
  619.    Try to make your bug report self-contained.  If we have to ask you
  620. for more information, it is best if you include all the previous
  621. information in your response, as well as the information that was
  622. missing.
  623.  
  624.    Please report each bug in a separate message.  This makes it easier
  625. for us to track which bugs have been fixed and to forward your bugs
  626. reports to the appropriate maintainer.
  627.  
  628.    To enable someone to investigate the bug, you should include all
  629. these things:
  630.  
  631.    * The version of GCC.  You can get this by running it with the `-v'
  632.      option.
  633.  
  634.      Without this, we won't know whether there is any point in looking
  635.      for the bug in the current version of GCC.
  636.  
  637.    * A complete input file that will reproduce the bug.  If the bug is
  638.      in the C preprocessor, send a source file and any header files
  639.      that it requires.  If the bug is in the compiler proper (`cc1'),
  640.      send the preprocessor output generated by adding `-save-temps' to
  641.      the compilation command (*note Debugging Options::.).  When you do
  642.      this, use the same `-I', `-D' or `-U' options that you used in
  643.      actual compilation. Then send the INPUT.i or INPUT.ii files
  644.      generated.
  645.  
  646.      A single statement is not enough of an example.  In order to
  647.      compile it, it must be embedded in a complete file of compiler
  648.      input; and the bug might depend on the details of how this is done.
  649.  
  650.      Without a real example one can compile, all anyone can do about
  651.      your bug report is wish you luck.  It would be futile to try to
  652.      guess how to provoke the bug.  For example, bugs in register
  653.      allocation and reloading frequently depend on every little detail
  654.      of the function they happen in.
  655.  
  656.      Even if the input file that fails comes from a GNU program, you
  657.      should still send the complete test case.  Don't ask the GCC
  658.      maintainers to do the extra work of obtaining the program in
  659.      question--they are all overworked as it is.  Also, the problem may
  660.      depend on what is in the header files on your system; it is
  661.      unreliable for the GCC maintainers to try the problem with the
  662.      header files available to them.  By sending CPP output, you can
  663.      eliminate this source of uncertainty and save us a certain
  664.      percentage of wild goose chases.
  665.  
  666.    * The command arguments you gave GCC to compile that example and
  667.      observe the bug.  For example, did you use `-O'?  To guarantee you
  668.      won't omit something important, list all the options.
  669.  
  670.      If we were to try to guess the arguments, we would probably guess
  671.      wrong and then we would not encounter the bug.
  672.  
  673.    * The type of machine you are using, and the operating system name
  674.      and version number.
  675.  
  676.    * The operands you gave to the `configure' command when you installed
  677.      the compiler.
  678.  
  679.    * A complete list of any modifications you have made to the compiler
  680.      source.  (We don't promise to investigate the bug unless it
  681.      happens in an unmodified compiler.  But if you've made
  682.      modifications and don't tell us, then you are sending us on a wild
  683.      goose chase.)
  684.  
  685.      Be precise about these changes.  A description in English is not
  686.      enough--send a context diff for them.
  687.  
  688.      Adding files of your own (such as a machine description for a
  689.      machine we don't support) is a modification of the compiler source.
  690.  
  691.    * Details of any other deviations from the standard procedure for
  692.      installing GCC.
  693.  
  694.    * A description of what behavior you observe that you believe is
  695.      incorrect.  For example, "The compiler gets a fatal signal," or,
  696.      "The assembler instruction at line 208 in the output is incorrect."
  697.  
  698.      Of course, if the bug is that the compiler gets a fatal signal,
  699.      then one can't miss it.  But if the bug is incorrect output, the
  700.      maintainer might not notice unless it is glaringly wrong.  None of
  701.      us has time to study all the assembler code from a 50-line C
  702.      program just on the chance that one instruction might be wrong.
  703.      We need *you* to do this part!
  704.  
  705.      Even if the problem you experience is a fatal signal, you should
  706.      still say so explicitly.  Suppose something strange is going on,
  707.      such as, your copy of the compiler is out of synch, or you have
  708.      encountered a bug in the C library on your system.  (This has
  709.      happened!)  Your copy might crash and the copy here would not.  If
  710.      you said to expect a crash, then when the compiler here fails to
  711.      crash, we would know that the bug was not happening.  If you don't
  712.      say to expect a crash, then we would not know whether the bug was
  713.      happening.  We would not be able to draw any conclusion from our
  714.      observations.
  715.  
  716.      If the problem is a diagnostic when compiling GCC with some other
  717.      compiler, say whether it is a warning or an error.
  718.  
  719.      Often the observed symptom is incorrect output when your program
  720.      is run.  Sad to say, this is not enough information unless the
  721.      program is short and simple.  None of us has time to study a large
  722.      program to figure out how it would work if compiled correctly,
  723.      much less which line of it was compiled wrong.  So you will have
  724.      to do that.  Tell us which source line it is, and what incorrect
  725.      result happens when that line is executed.  A person who
  726.      understands the program can find this as easily as finding a bug
  727.      in the program itself.
  728.  
  729.    * If you send examples of assembler code output from GCC, please use
  730.      `-g' when you make them.  The debugging information includes
  731.      source line numbers which are essential for correlating the output
  732.      with the input.
  733.  
  734.    * If you wish to mention something in the GCC source, refer to it by
  735.      context, not by line number.
  736.  
  737.      The line numbers in the development sources don't match those in
  738.      your sources.  Your line numbers would convey no useful
  739.      information to the maintainers.
  740.  
  741.    * Additional information from a debugger might enable someone to
  742.      find a problem on a machine which he does not have available.
  743.      However, you need to think when you collect this information if
  744.      you want it to have any chance of being useful.
  745.  
  746.      For example, many people send just a backtrace, but that is never
  747.      useful by itself.  A simple backtrace with arguments conveys little
  748.      about GCC because the compiler is largely data-driven; the same
  749.      functions are called over and over for different RTL insns, doing
  750.      different things depending on the details of the insn.
  751.  
  752.      Most of the arguments listed in the backtrace are useless because
  753.      they are pointers to RTL list structure.  The numeric values of the
  754.      pointers, which the debugger prints in the backtrace, have no
  755.      significance whatever; all that matters is the contents of the
  756.      objects they point to (and most of the contents are other such
  757.      pointers).
  758.  
  759.      In addition, most compiler passes consist of one or more loops that
  760.      scan the RTL insn sequence.  The most vital piece of information
  761.      about such a loop--which insn it has reached--is usually in a
  762.      local variable, not in an argument.
  763.  
  764.      What you need to provide in addition to a backtrace are the values
  765.      of the local variables for several stack frames up.  When a local
  766.      variable or an argument is an RTX, first print its value and then
  767.      use the GDB command `pr' to print the RTL expression that it points
  768.      to.  (If GDB doesn't run on your machine, use your debugger to call
  769.      the function `debug_rtx' with the RTX as an argument.)  In
  770.      general, whenever a variable is a pointer, its value is no use
  771.      without the data it points to.
  772.  
  773.    Here are some things that are not necessary:
  774.  
  775.    * A description of the envelope of the bug.
  776.  
  777.      Often people who encounter a bug spend a lot of time investigating
  778.      which changes to the input file will make the bug go away and which
  779.      changes will not affect it.
  780.  
  781.      This is often time consuming and not very useful, because the way
  782.      we will find the bug is by running a single example under the
  783.      debugger with breakpoints, not by pure deduction from a series of
  784.      examples.  You might as well save your time for something else.
  785.  
  786.      Of course, if you can find a simpler example to report *instead* of
  787.      the original one, that is a convenience.  Errors in the output
  788.      will be easier to spot, running under the debugger will take less
  789.      time, etc.  Most GCC bugs involve just one function, so the most
  790.      straightforward way to simplify an example is to delete all the
  791.      function definitions except the one where the bug occurs.  Those
  792.      earlier in the file may be replaced by external declarations if
  793.      the crucial function depends on them.  (Exception: inline
  794.      functions may affect compilation of functions defined later in the
  795.      file.)
  796.  
  797.      However, simplification is not vital; if you don't want to do this,
  798.      report the bug anyway and send the entire test case you used.
  799.  
  800.    * In particular, some people insert conditionals `#ifdef BUG' around
  801.      a statement which, if removed, makes the bug not happen.  These
  802.      are just clutter; we won't pay any attention to them anyway.
  803.      Besides, you should send us cpp output, and that can't have
  804.      conditionals.
  805.  
  806.    * A patch for the bug.
  807.  
  808.      A patch for the bug is useful if it is a good one.  But don't omit
  809.      the necessary information, such as the test case, on the
  810.      assumption that a patch is all we need.  We might see problems
  811.      with your patch and decide to fix the problem another way, or we
  812.      might not understand it at all.
  813.  
  814.      Sometimes with a program as complicated as GCC it is very hard to
  815.      construct an example that will make the program follow a certain
  816.      path through the code.  If you don't send the example, we won't be
  817.      able to construct one, so we won't be able to verify that the bug
  818.      is fixed.
  819.  
  820.      And if we can't understand what bug you are trying to fix, or why
  821.      your patch should be an improvement, we won't install it.  A test
  822.      case will help us to understand.
  823.  
  824.      *Note Sending Patches::, for guidelines on how to make it easy for
  825.      us to understand and install your patches.
  826.  
  827.    * A guess about what the bug is or what it depends on.
  828.  
  829.      Such guesses are usually wrong.  Even I can't guess right about
  830.      such things without first using the debugger to find the facts.
  831.  
  832.    * A core dump file.
  833.  
  834.      We have no way of examining a core dump for your type of machine
  835.      unless we have an identical system--and if we do have one, we
  836.      should be able to reproduce the crash ourselves.
  837.  
  838. 
  839. File: gcc.info,  Node: Sending Patches,  Prev: Bug Reporting,  Up: Bugs
  840.  
  841. Sending Patches for GCC
  842. =======================
  843.  
  844.    If you would like to write bug fixes or improvements for the GNU C
  845. compiler, that is very helpful.  Send suggested fixes to the patches
  846. mailing list, `gcc-patches@gcc.gnu.org'.
  847.  
  848.    Please follow these guidelines so we can study your patches
  849. efficiently.  If you don't follow these guidelines, your information
  850. might still be useful, but using it will take extra work.  Maintaining
  851. GNU C is a lot of work in the best of circumstances, and we can't keep
  852. up unless you do your best to help.
  853.  
  854.    * Send an explanation with your changes of what problem they fix or
  855.      what improvement they bring about.  For a bug fix, just include a
  856.      copy of the bug report, and explain why the change fixes the bug.
  857.  
  858.      (Referring to a bug report is not as good as including it, because
  859.      then we will have to look it up, and we have probably already
  860.      deleted it if we've already fixed the bug.)
  861.  
  862.    * Always include a proper bug report for the problem you think you
  863.      have fixed.  We need to convince ourselves that the change is
  864.      right before installing it.  Even if it is right, we might have
  865.      trouble judging it if we don't have a way to reproduce the problem.
  866.  
  867.    * Include all the comments that are appropriate to help people
  868.      reading the source in the future understand why this change was
  869.      needed.
  870.  
  871.    * Don't mix together changes made for different reasons.  Send them
  872.      *individually*.
  873.  
  874.      If you make two changes for separate reasons, then we might not
  875.      want to install them both.  We might want to install just one.  If
  876.      you send them all jumbled together in a single set of diffs, we
  877.      have to do extra work to disentangle them--to figure out which
  878.      parts of the change serve which purpose.  If we don't have time
  879.      for this, we might have to ignore your changes entirely.
  880.  
  881.      If you send each change as soon as you have written it, with its
  882.      own explanation, then the two changes never get tangled up, and we
  883.      can consider each one properly without any extra work to
  884.      disentangle them.
  885.  
  886.      Ideally, each change you send should be impossible to subdivide
  887.      into parts that we might want to consider separately, because each
  888.      of its parts gets its motivation from the other parts.
  889.  
  890.    * Send each change as soon as that change is finished.  Sometimes
  891.      people think they are helping us by accumulating many changes to
  892.      send them all together.  As explained above, this is absolutely
  893.      the worst thing you could do.
  894.  
  895.      Since you should send each change separately, you might as well
  896.      send it right away.  That gives us the option of installing it
  897.      immediately if it is important.
  898.  
  899.    * Use `diff -c' to make your diffs.  Diffs without context are hard
  900.      for us to install reliably.  More than that, they make it hard for
  901.      us to study the diffs to decide whether we want to install them.
  902.      Unidiff format is better than contextless diffs, but not as easy
  903.      to read as `-c' format.
  904.  
  905.      If you have GNU diff, use `diff -cp', which shows the name of the
  906.      function that each change occurs in.
  907.  
  908.    * Write the change log entries for your changes.  We get lots of
  909.      changes, and we don't have time to do all the change log writing
  910.      ourselves.
  911.  
  912.      Read the `ChangeLog' file to see what sorts of information to put
  913.      in, and to learn the style that we use.  The purpose of the change
  914.      log is to show people where to find what was changed.  So you need
  915.      to be specific about what functions you changed; in large
  916.      functions, it's often helpful to indicate where within the
  917.      function the change was.
  918.  
  919.      On the other hand, once you have shown people where to find the
  920.      change, you need not explain its purpose.  Thus, if you add a new
  921.      function, all you need to say about it is that it is new.  If you
  922.      feel that the purpose needs explaining, it probably does--but the
  923.      explanation will be much more useful if you put it in comments in
  924.      the code.
  925.  
  926.      If you would like your name to appear in the header line for who
  927.      made the change, send us the header line.
  928.  
  929.    * When you write the fix, keep in mind that we can't install a
  930.      change that would break other systems.
  931.  
  932.      People often suggest fixing a problem by changing
  933.      machine-independent files such as `toplev.c' to do something
  934.      special that a particular system needs.  Sometimes it is totally
  935.      obvious that such changes would break GCC for almost all users.
  936.      We can't possibly make a change like that.  At best it might tell
  937.      us how to write another patch that would solve the problem
  938.      acceptably.
  939.  
  940.      Sometimes people send fixes that *might* be an improvement in
  941.      general--but it is hard to be sure of this.  It's hard to install
  942.      such changes because we have to study them very carefully.  Of
  943.      course, a good explanation of the reasoning by which you concluded
  944.      the change was correct can help convince us.
  945.  
  946.      The safest changes are changes to the configuration files for a
  947.      particular machine.  These are safe because they can't create new
  948.      bugs on other machines.
  949.  
  950.      Please help us keep up with the workload by designing the patch in
  951.      a form that is good to install.
  952.  
  953. 
  954. File: gcc.info,  Node: Service,  Next: Contributing,  Prev: Bugs,  Up: Top
  955.  
  956. How To Get Help with GCC
  957. ************************
  958.  
  959.    If you need help installing, using or changing GCC, there are two
  960. ways to find it:
  961.  
  962.    * Send a message to a suitable network mailing list.  First try
  963.      `gcc-bugs@gcc.gnu.org' or `bug-gcc@gnu.org', and if that brings no
  964.      response, try `gcc@gcc.gnu.org'.
  965.  
  966.    * Look in the service directory for someone who might help you for a
  967.      fee.  The service directory is found in the file named `SERVICE'
  968.      in the GCC distribution.
  969.  
  970. 
  971. File: gcc.info,  Node: Contributing,  Next: VMS,  Prev: Service,  Up: Top
  972.  
  973. Contributing to GCC Development
  974. *******************************
  975.  
  976.    If you would like to help pretest GCC releases to assure they work
  977. well, or if you would like to work on improving GCC, please contact the
  978. maintainers at `gcc@gcc.gnu.org'.  A pretester should be willing to try
  979. to investigate bugs as well as report them.
  980.  
  981.    If you'd like to work on improvements, please ask for suggested
  982. projects or suggest your own ideas.  If you have already written an
  983. improvement, please tell us about it.  If you have not yet started
  984. work, it is useful to contact `gcc@gcc.gnu.org' before you start; the
  985. maintainers may be able to suggest ways to make your extension fit in
  986. better with the rest of GCC and with other development plans.
  987.  
  988. 
  989. File: gcc.info,  Node: VMS,  Next: Portability,  Prev: Contributing,  Up: Top
  990.  
  991. Using GCC on VMS
  992. ****************
  993.  
  994.    Here is how to use GCC on VMS.
  995.  
  996. * Menu:
  997.  
  998. * Include Files and VMS::  Where the preprocessor looks for the include files.
  999. * Global Declarations::    How to do globaldef, globalref and globalvalue with
  1000.                            GCC.
  1001. * VMS Misc::           Misc information.
  1002.  
  1003. 
  1004. File: gcc.info,  Node: Include Files and VMS,  Next: Global Declarations,  Up: VMS
  1005.  
  1006. Include Files and VMS
  1007. =====================
  1008.  
  1009.    Due to the differences between the filesystems of Unix and VMS, GCC
  1010. attempts to translate file names in `#include' into names that VMS will
  1011. understand.  The basic strategy is to prepend a prefix to the
  1012. specification of the include file, convert the whole filename to a VMS
  1013. filename, and then try to open the file.  GCC tries various prefixes
  1014. one by one until one of them succeeds:
  1015.  
  1016.   1. The first prefix is the `GNU_CC_INCLUDE:' logical name: this is
  1017.      where GNU C header files are traditionally stored.  If you wish to
  1018.      store header files in non-standard locations, then you can assign
  1019.      the logical `GNU_CC_INCLUDE' to be a search list, where each
  1020.      element of the list is suitable for use with a rooted logical.
  1021.  
  1022.   2. The next prefix tried is `SYS$SYSROOT:[SYSLIB.]'.  This is where
  1023.      VAX-C header files are traditionally stored.
  1024.  
  1025.   3. If the include file specification by itself is a valid VMS
  1026.      filename, the preprocessor then uses this name with no prefix in
  1027.      an attempt to open the include file.
  1028.  
  1029.   4. If the file specification is not a valid VMS filename (i.e. does
  1030.      not contain a device or a directory specifier, and contains a `/'
  1031.      character), the preprocessor tries to convert it from Unix syntax
  1032.      to VMS syntax.
  1033.  
  1034.      Conversion works like this: the first directory name becomes a
  1035.      device, and the rest of the directories are converted into
  1036.      VMS-format directory names.  For example, the name `X11/foobar.h'
  1037.      is translated to `X11:[000000]foobar.h' or `X11:foobar.h',
  1038.      whichever one can be opened.  This strategy allows you to assign a
  1039.      logical name to point to the actual location of the header files.
  1040.  
  1041.   5. If none of these strategies succeeds, the `#include' fails.
  1042.  
  1043.    Include directives of the form:
  1044.  
  1045.      #include foobar
  1046.  
  1047. are a common source of incompatibility between VAX-C and GCC.  VAX-C
  1048. treats this much like a standard `#include <foobar.h>' directive.  That
  1049. is incompatible with the ANSI C behavior implemented by GCC: to expand
  1050. the name `foobar' as a macro.  Macro expansion should eventually yield
  1051. one of the two standard formats for `#include':
  1052.  
  1053.      #include "FILE"
  1054.      #include <FILE>
  1055.  
  1056.    If you have this problem, the best solution is to modify the source
  1057. to convert the `#include' directives to one of the two standard forms.
  1058. That will work with either compiler.  If you want a quick and dirty fix,
  1059. define the file names as macros with the proper expansion, like this:
  1060.  
  1061.      #define stdio <stdio.h>
  1062.  
  1063. This will work, as long as the name doesn't conflict with anything else
  1064. in the program.
  1065.  
  1066.    Another source of incompatibility is that VAX-C assumes that:
  1067.  
  1068.      #include "foobar"
  1069.  
  1070. is actually asking for the file `foobar.h'.  GCC does not make this
  1071. assumption, and instead takes what you ask for literally; it tries to
  1072. read the file `foobar'.  The best way to avoid this problem is to
  1073. always specify the desired file extension in your include directives.
  1074.  
  1075.    GCC for VMS is distributed with a set of include files that is
  1076. sufficient to compile most general purpose programs.  Even though the
  1077. GCC distribution does not contain header files to define constants and
  1078. structures for some VMS system-specific functions, there is no reason
  1079. why you cannot use GCC with any of these functions.  You first may have
  1080. to generate or create header files, either by using the public domain
  1081. utility `UNSDL' (which can be found on a DECUS tape), or by extracting
  1082. the relevant modules from one of the system macro libraries, and using
  1083. an editor to construct a C header file.
  1084.  
  1085.    A `#include' file name cannot contain a DECNET node name.  The
  1086. preprocessor reports an I/O error if you attempt to use a node name,
  1087. whether explicitly, or implicitly via a logical name.
  1088.  
  1089.